package td0.shape;

import main.Point;

public final class RevolutionCone extends Shape3D {

	private double height;
	private double radius;
	private Point center;

	public RevolutionCone(double height, double radius, Point center) {
		super("RevolutionCone");
		this.height = height;
		this.radius = radius;
		this.center = new Point(center.getX(), center.getY());
	}

	public RevolutionCone(double radius, Point center) {
		super("RevolutionCone");
		this.height = 0;
		this.radius = radius;
		this.center = new Point(center.getX(), center.getY());
	}

	@Override
	public double volume() {
		return (Math.PI * radius * radius * height) / 3;
	}

	@Override
	public void translate(int dx, int dy) {
		center.setX(center.getX() + dx);
		center.setY(center.getY() + dy);
	}

	public double apothem() {
		return Math.sqrt(radius * radius + height * height);
	}

	@Override
	public double surface() {
		return Math.PI * radius * (radius + apothem());
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == null)
			return false;

		if (obj == this)
			return true;

		if (!this.getClass().equals(obj.getClass()))
			return false;

		RevolutionCone rc = (RevolutionCone) obj;
		return rc.radius == this.radius && rc.center.equals(this.center)
				&& rc.height == this.height;
	}

	@Override
	public String toString() {
		return "RevolutionCone [height=" + height + ", radius=" + radius
				+ ", center=" + center + "]";
	}
}
